package com.dftdla.dao.pojo;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

import com.dftdla.server.message.request.GroupChatRequestMessage;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 *
 * @author 14501
 * @TableName chat_group_msg
 */
@EqualsAndHashCode(callSuper = false)
@TableName(value ="chat_group_msg")
@Data
public class ChatGroupMsg implements Serializable {

    /**
     *
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     *
     */
    private Long chatUser;

    /**
     *
     */
    private Long chatGroup;

    /**
     *
     */
    private String text;


    /**
     *
     */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     *
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public ChatGroupMsg(GroupChatRequestMessage msg) {
        this.chatUser = msg.getFrom();
        this.chatGroup = msg.getGroupId();
        this.text = msg.getContent();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", chatUser=").append(chatUser);
        sb.append(", chatGroup=").append(chatGroup);
        sb.append(", text=").append(text);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
